package com.itheima.Example;

public class ExamplePoker {
    public static void main(String[] args) {
        start();
    }
    public static void start() {
        String [] poker = new String[54]; // 初始化54张牌
        String[] colors = {"♥", "♠", "♣", "♦"}; // 花色
        String[] numbers = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
        int index = 0;

        for (int i = 0; i < numbers.length; i++) {
            for (int j = 0; j <colors.length; j++) {
               String str = numbers[i] + colors[j];
               poker[index] = str;
               index++;
            }
        }
        poker[index++] = "小王";
        poker[index] = "大王";
        for (int i = 0; i < poker.length; i++) {
            System.out.print(poker[i] +  "\t");
        }
        System.out.println();
        System.out.println("------------------------------------洗牌");
        changePoker(poker);
    }
    public static void changePoker(String[] arr) {
        for (int i = 0; i < arr.length; i++) {
            int index = (int)(Math.random() * arr.length); // 随机索引
            String current = arr[i],
                   change  = arr[index];

            arr[i] = change;
            arr[index] = current;
        }

        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] +  "\t");
        }
    }
}
